package com.cssl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author: chen
 * @Date: 2021/11/10 15:00
 * @Desc:
 */
@Controller
@Slf4j
public class LoggerController {
    @Autowired
    KafkaTemplate<String, String> kafkaTemplate;

    @RequestMapping("/applog")
    @ResponseBody
    public String getLog(@RequestParam("param") String jsonStr) {
        // 日志落盘
        log.info(jsonStr);
        // 数据写入kafka
        kafkaTemplate.send("ods_base_log", jsonStr);
        return "success";
    }
}
